package com.iyao_app.im.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.RelativeLayout;

import com.iyao_app.MyApplication;
import com.iyao_app.R;
import com.iyao_app.base.BaseActivityWithHead;
import com.iyao_app.http.BaseUrl;
import com.iyao_app.mvp.login.LoginActivity;
import com.iyao_app.util.Contants;
import com.iyao_app.util.DbUtil;
import com.iyao_app.util.ResourcesUtils;
import com.netease.nimlib.sdk.NIMClient;
import com.netease.nimlib.sdk.auth.AuthService;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class SystemSettingsActivity extends BaseActivityWithHead {


    @BindView(R.id.account_number)
    RelativeLayout mAccountNumber;
    @BindView(R.id.feedback)
    RelativeLayout mFeedback;
    @BindView(R.id.about_us)
    RelativeLayout mAboutUs;
    @BindView(R.id.customer_service_hotline)
    RelativeLayout mCustomerServiceHotline;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_system_settings);
        ButterKnife.bind(this);
        initData();

    }

    private void initData() {
        setTitleTV(ResourcesUtils.getString(R.string.system_settings));
    }

    @OnClick({R.id.account_number, R.id.feedback, R.id.about_us, R.id.customer_service_hotline, R.id.tv_login})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.account_number:
                startActivity(new Intent(this, ModificationPasswordActivity.class));
                break;
            case R.id.feedback:
                startActivity(new Intent(this, FeedbackActivity.class));
                break;
            case R.id.about_us:
                Intent intent1 = new Intent(this, AboutUsActivity.class);
                intent1.putExtra(Contants.OTHER_FIELD,"关于我们");
                intent1.putExtra(Contants.TYPE, BaseUrl.getAbout());
                startActivity(intent1);
                break;
            case R.id.customer_service_hotline:
                break;
            case R.id.tv_login://退出登陆
                DbUtil.clearDb();
                Intent intent = new Intent(this, LoginActivity.class);
                startActivity(intent);
                finish();
                List<Activity> allActivities = MyApplication.getInstance().allActivities;
                if (allActivities.size() > 1) {
                    if (allActivities.size() > 2) {
                        allActivities.get(1).finish();
                    }
                    allActivities.get(0).finish();
                }
                NIMClient.getService(AuthService.class).logout();
                break;

        }
    }
}
